//
//  LPKTableViewController.m
//  Demo-01
//
//  Created by 李平宽 on 2017/1/20.
//  Copyright © 2017年 com.lpk. All rights reserved.
//

#import "LPKTabController.h"
#import "LPKNavController.h"
@interface LPKTabController ()

@end

@implementation LPKTabController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    UIViewController *vc1 = [self loadChildViewControllerWithClassName:@"LPKHomeController" andTitle:@"首页" andImageName:@"tabbar_home"];
    UIViewController *vc2 = [self loadChildViewControllerWithClassName:@"LPKMessageController" andTitle:@"消息" andImageName:@"tabbar_message_center"];
    UIViewController *vc3 = [self loadChildViewControllerWithClassName:@"LPKDiscoverController" andTitle:@"发现" andImageName:@"tabbar_discover"];
    UIViewController *vc4 = [self loadChildViewControllerWithClassName:@"LPKMeController" andTitle:@"我的" andImageName:@"tabbar_profile"];
    
    self.viewControllers = @[vc1, vc2, vc3, vc4];
    
    
}

- (UIViewController *)loadChildViewControllerWithClassName:(NSString *)className andTitle:(NSString *)title andImageName:(NSString *)imageName {
   
    Class class =  NSClassFromString(className);

    UIViewController *vc = [[class alloc] init];
    
   
    vc.title = title;
   
    vc.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAutomatic];
   
    NSString *selectedImageName = [imageName stringByAppendingString:@"_selected"];
    
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAutomatic];
    
    vc.view.backgroundColor =  [UIColor whiteColor];
    
   
    LPKNavController *nav = [[LPKNavController alloc] initWithRootViewController:vc];

    return nav;
}



@end
